﻿using Microsoft.AspNetCore.Mvc;
using NewCodeAPI.IServices;
using NewCodeAPI.Models;

namespace NewCodeAPI.Controllers
{
    /// <summary>
    /// 基地相关操作
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class BaseController : Controller
    {
        private readonly IBaseService _baseService;

        /// <summary>
        /// 依赖注入
        /// </summary>
        /// <param name="baseService"></param>

        public BaseController(IBaseService baseService)
        {
            _baseService = baseService;
        }

        /// <summary>
        /// 查看基地信息
        /// </summary>
        /// <param name="area"></param>
        /// <returns></returns>
        [HttpGet]
        public List<MsgInfo> GetBaseInfo(string area)
        {
            return _baseService.GetBaseInfo(area);
        }

        /// <summary>
        /// 删除基地
        /// </summary>
        /// <param name="no"></param>
        /// <param name="area"></param>
        /// <returns></returns>
        [HttpDelete]

        public MsgInfo DeleteBase(int no, string area)
        {
            return _baseService.DeleteBase(no, area);
        }

        /// <summary>
        /// 添加基地信息
        /// </summary>
        /// <returns></returns>
        [HttpPost]

        public MsgInfo AddBase(BaseCourse baseCourse)
        {
            return _baseService.AddBase(baseCourse);
        }

        /// <summary>
        /// 修改基地信息
        /// </summary>
        /// <param name="no"></param>
        /// <param name="area"></param>
        /// <returns></returns>
        [HttpPut]

        public MsgInfo ModifyBase(int no, string area, BaseCourse baseCourse)
        {
            return _baseService.ModifyBase(no, area, baseCourse);
        }
    }
}
